#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
ENV TZ="Asia/Shanghai"

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["microservice/ProductService/NuGet.Config", "microservice/ProductService/"]
COPY ["microservice/ProductService/src/ProductService.HttpApi.Host/ProductService.HttpApi.Host.csproj", "microservice/ProductService/src/ProductService.HttpApi.Host/"]
COPY ["microservice/ProductService/src/ProductService.EntityFrameworkCore/ProductService.EntityFrameworkCore.csproj", "microservice/ProductService/src/ProductService.EntityFrameworkCore/"]
COPY ["microservice/ProductService/src/ProductService.Domain/ProductService.Domain.csproj", "microservice/ProductService/src/ProductService.Domain/"]
COPY ["microservice/ProductService/src/ProductService.Domain.Shared/ProductService.Domain.Shared.csproj", "microservice/ProductService/src/ProductService.Domain.Shared/"]
COPY ["shared/Microservice.Shared/Microservice.Shared.csproj", "shared/Microservice.Shared/"]
COPY ["microservice/ProductService/src/ProductService.HttpApi/ProductService.HttpApi.csproj", "microservice/ProductService/src/ProductService.HttpApi/"]
COPY ["microservice/ProductService/src/ProductService.Application.Contracts/ProductService.Application.Contracts.csproj", "microservice/ProductService/src/ProductService.Application.Contracts/"]
COPY ["microservice/ProductService/src/ProductService.Application/ProductService.Application.csproj", "microservice/ProductService/src/ProductService.Application/"]
RUN dotnet restore "microservice/ProductService/src/ProductService.HttpApi.Host/ProductService.HttpApi.Host.csproj"
COPY . .
WORKDIR "/src/microservice/ProductService/src/ProductService.HttpApi.Host"
RUN dotnet build "ProductService.HttpApi.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ProductService.HttpApi.Host.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ProductService.HttpApi.Host.dll"]